Private Function DoInputBox(ByVal Prompt As String, Optional ByVal Title As Variant, Optional ByVal Default As Variant, Optional ByVal xpos As Variant, Optional ByVal ypos As Variant, Optional ByVal HelpFile As Variant, Optional ByVal Context As Variant, Optional ByVal MaxLength As Variant, Optional ByVal Flags As Variant, Optional ByVal PasswordChar As Variant) As Variant
' Slave function to implement InputBox, InputLCase, InputUCase and InputPassword
Dim AppHelpFile As String
AppHelpFile = App.HelpFile
Load InputForm
With InputForm
' Set coordinates
CenterToParent InputForm
If IsNumeric(xpos) Then .Left = CLng(xpos)
If IsNumeric(ypos) Then .Top = CLng(ypos)
' Set helpfile and context id
If Not IsMissing(HelpFile) Then App.HelpFile = Format(HelpFile)
If IsNumeric(Context) Then .HelpContextID = CLng(Context)
' Set Flags
If Not IsMissing(Flags) Then
' Password
If Flags And IBPassword Then
If Not IsMissing(PasswordChar) And Not IsNull(PasswordChar) Then
.Answer.PasswordChar = CStr(PasswordChar)
Else
.Answer.PasswordChar = IBDefaultPasswordChar
End If
End If
If Flags And IBUcase Then
.CharCase = IBUcase
ElseIf Flags And IBLcase Then
.CharCase = IBLcase
Else
.CharCase = 0
End If
End If
' Set prompt, title
.Question = Prompt
If Not IsMissing(Title) And Not IsNull(Title) Then
.Caption = CStr(Title)
Else
.Caption = App.Title
End If
' Set default string and maximum length
If IsNumeric(MaxLength) Then
.Answer.MaxLength = CLng(MaxLength)
If Not IsMissing(Default) And Not IsNull(Default) Then .Answer = Left(CStr(Default), CLng(MaxLength))
Else
If Not IsMissing(Default) And Not IsNull(Default) Then .Answer = CStr(Default)
End If
' Show the form
.Show vbModal
If .Tag = "OK" Then
' If the user pressed OK, return the Answer
DoInputBox = .Answer
Else
' If the user pressed Cancel, return Null
DoInputBox = IBValueOnCancel
End If
End With
Unload InputForm
App.HelpFile = AppHelpFile
End Function
#If UseBuiltInInputBox = False Then
Public Function InputBox(ByVal Prompt As String, Optional ByVal Title As Variant, Optional ByVal Default As Variant, Optional ByVal xpos As Variant, Optional ByVal ypos As Variant, Optional ByVal HelpFile As Variant, Optional ByVal Context As Variant, Optional ByVal MaxLength As Variant) As Variant
' This corresponds to VB's InputBox(prompt[, title][, default][, xpos][, ypos][, helpfile, context])
Public Function InputLCase(ByVal Prompt As String, Optional ByVal Title As Variant, Optional ByVal Default As Variant, Optional ByVal xpos As Variant, Optional ByVal ypos As Variant, Optional ByVal HelpFile As Variant, Optional ByVal Context As Variant, Optional ByVal MaxLength As Variant) As Variant
Public Function InputPassword(ByVal Prompt As String, Optional ByVal Title As Variant, Optional ByVal Default As Variant, Optional ByVal xpos As Variant, Optional ByVal ypos As Variant, Optional ByVal HelpFile As Variant, Optional ByVal Context As Variant, Optional ByVal MaxLength As Variant, Optional ByVal PasswordChar As Variant) As Variant
' Like InputBox but masks all input with PasswordChar (IBDefaultPasswordChar if PasswordChar is not set)
Public Function InputUCase(ByVal Prompt As String, Optional ByVal Title As Variant, Optional ByVal Default As Variant, Optional ByVal xpos As Variant, Optional ByVal ypos As Variant, Optional ByVal HelpFile As Variant, Optional ByVal Context As Variant, Optional ByVal MaxLength As Variant) As Variant